# coding:utf-8
from db.basic_db import db_session
from db.models import WeiXinData
from decorators.decorator import db_commit_decorator


@db_commit_decorator
def insert_weixin_data(weixin_data):
    db_session.add(weixin_data)
    db_session.commit()
    db_session.close()

def get_wx_by_mid(mid):
    return db_session.query(WeiXinData).filter(WeiXinData.weixin_id == mid).first()

if __name__=='__main__':
    from db.models import WeiXinData


    for i in range(1000):
        weixindata = WeiXinData()
        weixindata.weixin_id = '265256522'
        weixindata.weixin_cont = 'test'
        weixindata.weixin_title = 'test'
        weixindata.weixin_created = 'test'
        weixindata.weixin_created_name = 'test'
        weixindata.weixin_keyword = 'test'
        weixindata.admin_id = 'test'
        insert_weixin_data(weixindata)


